import React, {useState, useRef} from 'react';
import { history } from 'umi'
import { List,Icon } from 'antd-mobile'
import { ListView} from '@/components'
import { exampaperRead,getAnswerExamRecordDetail } from '@/services/edu'
import style from './index.less'


const ListItem = (props) => {
  
  return (
    
  //   <List.Item wrap className={style.listItem} thumb={props.status?<Icon type="check-circle"/>:<Icon type="cross-circle-o"/>} arrow="horizontal" multipleLine onClick={() => {history.push('/answer')}}>
  //   {props.title} 
  // </List.Item>{props.title} 
  <List.Item className={style.listItem} thumb={props.doRight?<div>正确</div>:<div className={style.error}>错误</div>} arrow="horizontal" multipleLine onClick={() => {history.push(`/history/analysis?isExam=1&id=${props.recordId}&itemOrder=${props.itemOrder}`)}}>
  <div dangerouslySetInnerHTML={{ __html:props.shortTitle}}></div>
</List.Item>
  );
};
function History() {
  const { query = {} } = history.location as any;
  const { id } = query;
  const params = useRef<any>({ rflag: 0 });
  const listViewRef = useRef<any>();

  const getData = async (pageNum, pageSize) => {
    
    
    
    const res = await getAnswerExamRecordDetail({recordId:id});
    if (res.code !== 1) return [];
    const {
      list=[]
    }= res.response
    
    if(list.length){
      return list.map((item,i)=>{
        return {
          ...item,
          recordId:id,
          itemOrder:i,
          content:item.userCorrect,
        }
      })
    }
    // if (Array.isArray(res?.response?.list)) return res.response.list;
    // return [{status:1,title:'题目标题题目标题题目标题题目标题题目标题题目标题'},
    // {status:0,title:'题目标题题目标题题目标题题目标题题目标题题目标题二'},
    // {status:1,title:'题目标题题目标题题目标题题目标题题目标题题目标题'},
    // {status:1,title:'题目标题题目标题题目标题题目标题题目标题题目标题'},
    // {status:1,title:'题目标题题目标题题目标题题目标题题目标题题目标题'},
    // {status:1,title:'题目标题题目标题题目标题题目标题题目标题题目标题题目标题题目标题题目标题题目标题题目标题题目标题题目标题题目标题题目标题题目标题题目标题题目标题'},
    // {status:1,title:'题目标题题目标题题目标题题目标题题目标题题目标题'}];
  };
  const row = (item) => {
    
    return<ListItem {...item} key={item.id} />;
  };
  return (
    <div>
      <div className={style.listWrpper}>
        <ListView ref={listViewRef} getData={getData} renderRow={row} />
      </div>
    </div>
  );
}

export default History;
